package code;

/**
 * This class is used to store the information of individuals such as name, where they live and the types 
 * of accounts and cards they have. 
 * @author justinwong
 *
 */
public class Account {
	private String fFirstName;
	private String fLastName;
	private String fStreet;
	private String fZipCode;
	private String fTown;
	private String fCountry;
	private int fAccountNum;
	
	private CheckingAccount fCheckingAccount;
	private SavingsAccount fSavingsAccount;
	private DebitCard fDebitCard;
	private CreditCard fCreditCard;
	
	/*creates a Account*/
	public Account(String first_name, String last_name, String street, String zipcode, String town, String country,
			int account_num, CheckingAccount chk_account, SavingsAccount sv_account, DebitCard db_card, CreditCard cc_card){
		
		fFirstName = first_name;
		fLastName = last_name;
		fStreet = street;
		fZipCode = zipcode;
		fTown = town;
		fCountry = country;
		fAccountNum = account_num;
		fCheckingAccount = chk_account;
		fSavingsAccount = sv_account;
		fDebitCard = db_card;
		fCreditCard = cc_card;
		
	}
	
	/**
	 * Account applies for a credit card
	 * @return boolean if sucessful. 
	 */
	public boolean applyForCreditCard()
	{
		if(fCheckingAccount.getBalance() < 0)
		{
			return false;
		}
		if(fCheckingAccount.getBalance() <= 2500)
		{
			fCreditCard = new CreditCard();
		}
		else
		{
			fCreditCard = new CreditCard(5000);
		}
		return true;
	}
	
	/**
	 * Prints the checking account info. 
	 */
	public void printChecking()
	{
		System.out.println("**************************************");
		System.out.println("Checking account:     " + fCheckingAccount.getAccountNumber());
		System.out.println("Account holder name: " + fFirstName + " " + fLastName);
		System.out.println("Address:             " + fStreet);
		System.out.print("                     " + fZipCode);
		System.out.println(" " + fTown);
		System.out.println(fCountry.toUpperCase());
		System.out.println("**************************************");
		System.out.println("Balance:  " + fCheckingAccount.getBalance());
		System.out.println("**************************************");
	}
	
	/**
	 * Prints the savings account info. 
	 */
	public void printSavings()
	{
		System.out.println("**************************************");
		System.out.println("Savings account:     " + fSavingsAccount.fAccountNumber);
		System.out.println("Account holder name: " + fFirstName + " " + fLastName);
		System.out.println("Address:             " + fStreet);
		System.out.print("                     " + fZipCode);
		System.out.println(" " + fTown);
		System.out.println(fCountry.toUpperCase());
		System.out.println("**************************************");
		System.out.println("Balance:  " + fSavingsAccount.fBalance);
		System.out.println("**************************************");
	}
	
	/*I would create getters and setters for the fields normally but due to time constraints I will leave that out*/

}
